import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './common/common.css'
import './common/iconfont.css'
import http from '../src/http/request'
import * as API from '@/http/api'
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import {Message,Slider} from 'element-ui'

Vue.use(Slider)
Vue.prototype.$message = Message;
NProgress.configure({
  easing: 'ease',  // 动画方式
  speed: 500,  // 递增进度条的速度
  showSpinner: false, // 是否显示加载ico
  trickleSpeed: 200, // 自动递增间隔
  minimum: 0.3 // 初始化时的最小百分比
})
//当路由进入前
router.beforeEach((to, from , next) => {
  // 每次切换页面时，调用进度条
  NProgress.start();
  // 这个一定要加，没有next()页面不会跳转的
  next();
});
//当路由进入后：关闭进度条
router.afterEach(() => {
  // 在即将进入新的页面组件前，关闭掉进度条
  NProgress.done()
})

import atm from '@/assets/lazyload.gif'
import VueLazyLoad from "vue-lazyload";
Vue.use(VueLazyLoad,{
  // 懒加载默认的图片
  loading:atm,
});


Vue.prototype.$API = API;
Vue.prototype.$http = http;
Vue.config.productionTip = false
router.beforeEach((to, from, next) => {
  // chrome
  document.body.scrollTop = 0
  // firefox
  document.documentElement.scrollTop = 0
  next()
})
Vue.prototype.$bus = new Vue()
new Vue({
  beforeCreate() {
    Vue.prototype.$bus = this
  },
  router,
  store,
  render: h => h(App)
}).$mount('#app')
